import pandas as pd
def calculate_final_score(input_id):
    df = pd.read_csv('scores.csv')
    required = ['A', 'B', 'C']
    optional = ['D', 'E', 'F', 'G', 'H', 'I']
    subject_stats = {}
    for subj in required + optional:
        m = df[subj].mean()
        s = df[subj].std()
        subject_stats[subj] = {'mean': m, 'std': s}
    sum_scores = []
    for _, row in df.iterrows():
        req_sum = 0.0
        opt_sum = 0.0
        for subj in required:
            x = row[subj]
            m = subject_stats[subj]['mean']
            s = subject_stats[subj]['std']
            if s == 0:
                z = 500
            else:
                z = ((x - m) / s) * 100 + 500
                z = round(z)
                z = max(100, min(900, z))
            req_sum += z * 1.5
        selected = [s for s in optional if pd.notna(row[s])]
        for subj in selected:
            x = row[subj]
            m = subject_stats[subj]['mean']
            s = subject_stats[subj]['std']
            z = ((x - m) / s) * 100 + 500
            z = round(z)
            z = max(100, min(900, z))
            opt_sum += z * 1.0
        total_score = req_sum + opt_sum
        sum_scores.append(total_score)
    sum_series = pd.Series(sum_scores)
    mean_total = sum_series.mean()
    std_total = sum_series.std()
    final_scores = []
    for score in sum_scores:
        if std_total == 0:
            final_z = 500
        else:
            final_z = ((score - mean_total) / std_total) * 100 + 500
            final_z = round(final_z)
            final_z = max(100, min(900, final_z))
        final_scores.append(final_z)
    df['final_score'] = final_scores
    result = df[df['id'] == input_id]['final_score'].values[0]
    return result
if __name__ == "__main__":
    input_id = int(input())
    print(calculate_final_score(input_id))
